<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
            <h4 class="modal-title" id="myModalLabel"><a href="javascript:;" id="toLogin">Login</a>|<a href="javascript:;" id="toRegister">Register</a></h4>
        </div>
        <div class="modal-body">
            <form role="form" id="modalForm">
            </form>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-primary" id="submitBtn">login</button>
        </div>
    </div>
</div>
<div id="loginDiv" style="display: none;">
    <div class="form-group">
        <label for="account" class="control-label">email</label>
        <input type="text" class="form-control" id="account" name="account">
    </div>
    <div class="form-group">
        <label for="password" class="control-label">password</label>
        <input type="password" class="form-control" id="password" name="password">
    </div>
</div>
<div id="registerDiv" style="display: none;">
    <div class="form-group">
        <label for="account" class="control-label">email</label>
        <input type="text" class="form-control" id="account" name="account">
    </div>
    <div class="form-group">
        <label for="password" class="control-label">password</label>
        <input type="password" class="form-control" id="password" name="password">
    </div>
    <div class="form-group">
        <label for="name" class="control-label">nickName</label>
        <input type="text" class="form-control" id="name" name="name">
    </div>
    <div class="form-group">
        <label for="homeUrl" class="control-label">home</label>
        <input type="text" class="form-control" id="homeUrl" name="homeUrl">
    </div>
    <div class="form-group">
        <label for="head" class="control-label">head</label>
        <input type="text" class="form-control" id="head" name="head">
    </div>
</div>
<script type="text/javascript">
    $(function () {
        $("#modalForm").html($("#loginDiv").html());
        $("#toLogin").click(function () {
            $("#submitBtn").text("login");
            $("#modalForm").html($("#loginDiv").html());
        });

        $("#toRegister").click(function () {
            $("#submitBtn").text("register");
            $("#modalForm").html($("#registerDiv").html());
        });

        $("#submitBtn").click(function () {
            var params = $("#modalForm").serializeArray();
            var text = $("#submitBtn").text();
            var url = "/visitor/"+text;
            $.post(url,params,function(data){
                if(data.flag){
                    $(".replyCls").click();
                }else{
                    alert(data.msg);
                }
            })
        });
    })
</script>